package com.dt76.smallloanbackendservice.service.zjs.impl;

import com.dt76.smallloanbackendservice.mapper.zjs.PowerMapper;
import com.dt76.smallloanbackendservice.mapper.zjs.UserMapper;
import com.dt76.smallloanbackendservice.pojo.zjs.User;
import com.dt76.smallloanbackendservice.service.zjs.PowerService;
import com.dt76.smallloanbackendservice.service.zjs.UserService;
import com.dt76.smallloanbackendservice.utils.Page;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PowerServiceImpl implements PowerService {

    @Autowired
    private PowerMapper powerMapper;

    @Override
    public Page qryPageAllPowerUser(int pageIndex,
                                   @Param("qryTime") int qryTime,
                                    @Param("qryNum") int qryNum,
                                    @Param("qryMoney") int qryMoney,
                                   @Param("qryType") int qryType,
                                  @Param("qryRank") int qryRank,
                                  @Param("qryLebal") int qryLebal
                                  ) {
        Page page = new Page();
        page.setPageIndex(pageIndex);//每次更新当前页
        //更新总条数
        page.setTotalCount(powerMapper.qryCount(qryTime,qryNum,qryMoney,qryType,qryRank,qryLebal));
        System.out.println("qryTime:"+qryTime);
        System.out.println("qryNum:"+qryNum);
        System.out.println("qryMoney:"+qryMoney);
        System.out.println("qryType:"+qryType);
        System.out.println("qryRank:"+qryRank);
//        System.out.println("qryLebal:"+qryLebal);
        System.out.println("page.getPageSize():"+page.getPageSize());
        System.out.println("page.getPageIndex()-1)*page.getPageSize():"+(page.getPageIndex()-1)*page.getPageSize());
        List<User> blackUserList =  powerMapper.qryPageAllPowerUser(
                (page.getPageIndex()-1)*page.getPageSize(),
                page.getPageSize(),qryTime,qryNum,qryMoney,qryType,qryRank,qryLebal);
        page.setRows(blackUserList);
        return page;
    }


}
